package com.xxbb.chapter_8.dome3;

import com.xxbb.util.tool.Tool;

public class MyThread implements Runnable {
    private String name;
    private Ticket ticket;

    public MyThread(String _name, Ticket _ticket) {
        this.name = _name;
        this.ticket = _ticket;
    }

    @Override
    public void run() {
        while (true) {

            int number= ticket.sell();
            if (number<=0) break;
            Tool.println(this.name+"售出了"+number);
            try {
                Thread.sleep(200);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
